package com.hn.zhijian.base.common.converter;

import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.ObjectSerializer;
import com.hn.zhijian.base.common.ApplicationBeanUtil;
import com.hn.zhijian.base.common.ConfigurationYmlProperty;
import java.lang.reflect.Type;

/**
 * @program: carl-main
 * @description: 文件路径类型自定义
 * @author: carl
 * @create: 2019-11-16 22:56
 **/
public class FileFastJsonConverter implements ObjectSerializer {
    @Override
    public void write(JSONSerializer jsonSerializer, Object object, Object o1, Type type, int i)  {
        //此处可以自定义你要写入的内容
        String prefix = config.getShowFilePathPrefix();
        jsonSerializer.write(prefix + object);

    }

    private static ConfigurationYmlProperty config;

    public FileFastJsonConverter() {
        config = ApplicationBeanUtil.getBean(ConfigurationYmlProperty.class);
    }
}
